<?

// SendUserMessages functions

function send_user_message_from_admin($db,$userID,$subject,$text){
   return (send_user_message($db,$userID,$subject,$text,"0","1"));
}

function send_user_message_from_system($db,$userID,$subject,$text){
   return (send_user_message($db,$userID,$subject,$text,"0","2"));
}

function send_user_message_from_user($db,$userID,$subject,$text,$senderUserID){
   return (send_user_message($db,$userID,$subject,$text,$senderUserID,"0"));
}

// BroadcastMessages functions 

function send_broadcast_message_from_admin($db,$subject,$text){
   return (send_user_message($db,"0",$subject,$text,"0","1"));
}

function send_broadcast_message_from_system($db,$subject,$text){
   return (send_user_message($db,"0",$subject,$text,"0","2"));
}

function send_broadcast_message_from_user($db,$subject,$text,$senderUserID){
   return (send_user_message($db,"0",$subject,$text,$senderUserID,"0"));
}

function send_user_message($db,$userID,$subject,$text,$senderID,$senderType){
   return ($db->query("INSERT INTO messages VALUES('', '0', '".into_db($subject)."','".into_db($text)."',NOW(),'$userID', '$senderID', '$senderType')")); 
}

// SendAdminMessages functions

function send_admin_message_from_system($db,$subject,$text){
   return (send_admin_message($db,$subject,$text,"0","2"));
}

function send_admin_message_from_user($db,$subject,$text,$senderUserID){
   return (send_admin_message($db,$subject,$text,$senderUserID,"0"));
}

function send_admin_message($db,$subject,$text,$senderID,$senderType){
   return ($db->query("INSERT INTO admin_messages VALUES('', '0', '".into_db($subject)."','".into_db($text)."',NOW(),'$senderID', '$senderType')")); 
}

?>
